<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">


    <body>
        <div class="post">

            <h2 class="title">Cadastro de Diploma</h2>

            <h:panelGroup id="painelMensagens" layout="block">
                <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
            </h:panelGroup>

            <div id="stylized" class="myform">

                <h:form>

                    <h:outputLabel>Aluno: <span class="small">Max 70 caracteres</span></h:outputLabel>
                    <h:inputText  value="#{DiplomaController.diploma.aluno}" required="true" requiredMessage="Nome requerido." />

                    <h:outputLabel>Tipo de Curso<span class="small">Selecione uma opção</span></h:outputLabel>
                    <h:selectOneMenu value="#{DiplomaController.tipoCurso}">
                        <f:ajax event="change" render="selectCurso" />
                        <f:selectItems value="#{CursoController.tiposCurso}" var="tipoC" itemLabel="#{tipoC.nome}"/>
                    </h:selectOneMenu>

                    <h:outputLabel>Curso<span class="small">Selecione uma opção</span></h:outputLabel>
                    <h:selectOneMenu id="selectCurso" value="#{DiplomaController.diploma.curso}">
                        <f:selectItems value="#{DiplomaController.cursos}" var="curs" itemLabel="#{curs.nome}" />
                    </h:selectOneMenu>

                    <h:outputLabel>E-Mail: <span class="small">Email Válido do Contato</span></h:outputLabel>
                    <h:inputText  value="#{DiplomaController.diploma.email}" required="true" requiredMessage="E-mail requerido." />

                    <h:outputText>Telefones</h:outputText>
                    <br />

                    <p:dialog header="Cadastro de Telefone" widgetVar="dlg1" modal="true">
                    <h:form>

                        <h:panelGrid columns="2" id="painel">

                            <h:outputLabel> DDD: <span class="small">Número do DDD.</span></h:outputLabel>
                            <h:inputText  value="#{DiplomaController.telefone.ddd}"  required="true" requiredMessage="DDD requerido." />

                            <h:outputLabel> Número: <span class="small">Número do Endereço.</span></h:outputLabel>
                            <h:inputText  value="#{DiplomaController.telefone.numero}"  required="true" requiredMessage="Número requerido." />

                            <h:outputLabel>Tipo de Telefone: <span class="small">Selecione um Tipo</span></h:outputLabel>
                            <h:selectOneMenu id="es" value="#{DiplomaController.telefone.tipo}" title="Selecione um estado civil">
                                <f:selectItems value="#{DiplomaController.tiposTelefones}" var="tt" itemLabel="#{tt.nome}" />
                            </h:selectOneMenu>

                        </h:panelGrid>

                        <h:commandButton styleClass="button" action="#{DiplomaController.addTelefone}" value="Salvar" />
                        <h:commandButton styleClass="button" type="reset" value="Limpar" />


                    </h:form>
                </p:dialog>

                
                    <h:commandButton styleClass="button" onclick="dlg1.show();" type="button"  value="Novo Telefone" />
                    <br />


                    <p:dataTable var="telefoneDiplomaAux" value="#{DiplomaController.telefonesDiplomas}" >
                        <p:column sortBy="#{telefoneDiplomaAux.telefone.ddd}">
                            <f:facet name="header">
                                <h:outputText value="DDD" />
                            </f:facet>
                            <h:outputText value="#{telefoneDiplomaAux.telefone.ddd}" />
                        </p:column>

                        <p:column sortBy="#{telefoneDiplomaAux.telefone.numero}">
                            <f:facet name="header">
                                <h:outputText value="Número" />
                            </f:facet>
                            <h:outputText value="#{telefoneDiplomaAux.telefone.numero}" />
                        </p:column>
                        <p:column sortBy="#{telefoneDiplomaAux.telefone.tipo}">
                            <f:facet name="header">
                                <h:outputText value="Tipo" />
                            </f:facet>
                            <h:outputText value="#{telefoneDiplomaAux.telefone.tipo.nome}" />
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Remover" />
                            </f:facet>
                            <h:commandLink action="#{DiplomaController.RemoverTelefone}" >Remove</h:commandLink>
                        </p:column>


                    </p:dataTable>

                    <h:commandButton styleClass="button" action="#{DiplomaController.persiste}" value="Salvar" />
                    <h:commandButton styleClass="button" type="reset" value="Limpar" />




                </h:form>
            </div>
        </div>




    </body>
</html>
